package com.dapeis.service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ag.dao.DBService;
import com.ag.dao.IDao;
import com.dapeis.core.utils.StringUtil;
import com.dapeis.core.utils.StylistConstants;
import com.dapeis.dao.ICosFileMapper;
import com.dapeis.domain.CosFile;

@Service
public class CosFileObjectService extends DBService<CosFile> {

    @Resource
    ICosFileMapper mapper;

    @Override
    protected IDao<CosFile> getIDao() {
	return mapper;
    }

    /**
     * 根据ID列表获取参数
     * @param idPath
     * @return
     */
    public List<CosFile> getFileById(String idPath) {
	if (StringUtil.isNotBlank(idPath)) {
	    String[] arrays = idPath.split("\\" + StylistConstants.SPE_SUX);
	    List list = new ArrayList();
	    for (String strId : arrays) {
		Long id = new Long(strId);
		CosFile cosFile = mapper.selectByPrimaryKey(id);
		if (null != cosFile) {
		    list.add(cosFile);
		}
	    }
	    return list;
	}
	return Collections.EMPTY_LIST;
    }
}
